using System;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json;

namespace GetKlient.utils
{
    public class HttpHelper
    {
        public static async Task<T?> MakeRequest<T>(string url,string payload,string contentType)
        {
            using (var httpClient = new HttpClient())
            {
                var content = new StringContent(payload, Encoding.UTF8, contentType);
                var response = await httpClient.PostAsync(url, content);
                response.EnsureSuccessStatusCode();
                var responseBody = await response.Content.ReadAsStringAsync();
               
                return JsonConvert.DeserializeObject<T>(responseBody);
               
            }
        }
    }
}